var url=require('url');

module.exports = function (req, res, next) {

    var user={
        token:'839ddc7a85ec438e954384829810f87a',
        user: {
            "token": "839ddc7a85ec438e954384829810f87a",
            "user": {
                "userId": 500,
                "token": "839ddc7a85ec438e954384829810f87a",
                "mobile": "17620310202",
                "nickName": "七秒记忆",
                "city": "深圳",
                "country": "中国",
                "headImgUrl": "http://wx.qlogo.cn/mmopen/9Qwa1wBPaMMicQd5oWibucLvatQ4F2uvsWApB2A44k4SicZM3Lzsfz4KQucHyFEgibkHG5d51NHkmticamIF5PsBRVLw1LibxLdKXe/0",
                "openId": "oU6EwwMIoCGBVrPWb2SBn27XZQ2Y",
                "ip": "183.16.189.129",
                "isSubscribe": 1,
                "lottery": false
            }
        }
    }
    req.session.user=user;


    /*var reqUrl = req.url.split('?')[0];
    var result=url.parse(req.url);
    if(result.pathname=='/login'){
        next();
    }else {*/
        console.log('session.user=============='+req.session.user);
        if(req.session.user){
            console.log('已经登录token=============='+req.session.user);
            next();
        }else{
            //登录接口
            console.log('调用登录接口==============');
            res.redirect('/api/login?token=839ddc7a85ec438e954384829810f87a');
        }
    //}
};